// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Mapping;

public sealed partial class SemanticTextProperty : IProperty
{
	[JsonInclude, JsonPropertyName("inference_id")]
	public Elastic.Clients.Elasticsearch.Id InferenceId { get; set; }
	[JsonInclude, JsonPropertyName("meta")]
	public IDictionary<string, string>? Meta { get; set; }

	[JsonInclude, JsonPropertyName("type")]
	public string Type => "semantic_text";
}

public sealed partial class SemanticTextPropertyDescriptor : SerializableDescriptor<SemanticTextPropertyDescriptor>, IBuildableDescriptor<SemanticTextProperty>
{
	internal SemanticTextPropertyDescriptor(Action<SemanticTextPropertyDescriptor> configure) => configure.Invoke(this);

	public SemanticTextPropertyDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Id InferenceIdValue { get; set; }
	private IDictionary<string, string>? MetaValue { get; set; }

	public SemanticTextPropertyDescriptor InferenceId(Elastic.Clients.Elasticsearch.Id inferenceId)
	{
		InferenceIdValue = inferenceId;
		return Self;
	}

	public SemanticTextPropertyDescriptor Meta(Func<FluentDictionary<string, string>, FluentDictionary<string, string>> selector)
	{
		MetaValue = selector?.Invoke(new FluentDictionary<string, string>());
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("inference_id");
		JsonSerializer.Serialize(writer, InferenceIdValue, options);
		if (MetaValue is not null)
		{
			writer.WritePropertyName("meta");
			JsonSerializer.Serialize(writer, MetaValue, options);
		}

		writer.WritePropertyName("type");
		writer.WriteStringValue("semantic_text");
		writer.WriteEndObject();
	}

	SemanticTextProperty IBuildableDescriptor<SemanticTextProperty>.Build() => new()
	{
		InferenceId = InferenceIdValue,
		Meta = MetaValue
	};
}